/*
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-05-19 14:18:41
 * @LastEditTime: 2022-05-19 15:30:51
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description:
 */
import { ref, watch } from 'vue'
import DynamicData from './DynamicData'
import { watchSwitchLang } from '@/utils/i18n'

// 复选框
export const dynamicData = ref(DynamicData())
// 选中项
export const checkedData = ref([])
function selectDynamicData() {
  checkedData.value = dynamicData.value.map(item => item.label)
}
selectDynamicData()

// 监听动态数据变化
export const tableColumn = ref([])
watch(checkedData, (v) => {
  tableColumn.value = dynamicData.value.filter(item => v.includes(item.label))
},
{ immediate: true })

// 监听语言变化
watchSwitchLang(() => {
  dynamicData.value = DynamicData()
  selectDynamicData()
})
